package f5transformation;

import flinkemp.Emp;
import flinkemp.EmpFun;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

//静态内部类
public class Map {
    public static void main(String[] args) throws Exception{
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        DataStreamSource<Emp> empDataStreamSource = env.addSource(new EmpFun());
        empDataStreamSource.print();
        //取出姓名
        SingleOutputStreamOperator<String> name = empDataStreamSource.map(new MyMap());

        name.print();
        env.execute();
    }

    public static class MyMap implements MapFunction<Emp,String> {
        @Override
        public String map(Emp emp) throws Exception{
            return "姓名:"+emp.eName;
        }
    }
}
